<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>货品信息编辑--${site.name}</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="format-detection" content="telephone=no">
<meta name="description" content="${site.description}" />
<meta name="keywords" content="${site.keywords}" />
<meta name="author" content="${site.author}" />
<link rel="icon" href="${site.logo}">
<link rel="stylesheet" href="${base}/static/layui/css/layui.css"
	media="all" />
<style type="text/css">
.layui-form-item .layui-inline {
	width: 33.333%;
	float: left;
	margin-right: 0;
}

@media ( max-width :1240px) {
	.layui-form-item .layui-inline {
		width: 100%;
		float: none;
	}
}

.layui-form-item .role-box {
	position: relative;
}

.layui-form-item .role-box .jq-role-inline {
	height: 100%;
	overflow: auto;
}
</style>
</head>
<body class="childrenBody">
	<form class="layui-form">
		<input value="${mallPSpu.id}" name="id" type="hidden">
		<input type="hidden" name="refOnecataId" id="refOnecataId" value="${mallPSpu.refOnecataId}">
		<input type="hidden" name="refTwocataId" id="refTwocataId" value="${mallPSpu.refTwocataId}">
		<div class="layui-form-item">
			<label class="layui-form-label"> <span class="required">*</span>
				分类
			</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" name="refcataid"
					id="refcataid" lay-verify="required" placeholder="选择分类"
					readonly="readonly">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"> <span class="required">*</span>
				名称
			</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" value="${mallPSpu.name}"
					name="name" lay-verify="required" placeholder="请输入名称">

			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"> <span class="required">*</span>
				spu编号
			</label>
			<div class="layui-input-block">
				<input type="text" class="layui-input" value="${mallPSpu.spuno}"
					name="spuno" lay-verify="required" placeholder="请输入spu编号">

			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"> 简介</label>
			<div class="layui-input-block">
				<textarea name="intro" placeholder="请输入简介" class="layui-textarea">${mallPSpu.intro}</textarea>

			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"> 详细介绍</label>
			<div class="layui-input-block">
				<div id="content">${mallPSpu.content}</div>

			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn" lay-submit="" lay-filter="addMallPSpu">立即提交</button>
				<button class="layui-btn layui-btn-primary"
					onclick="parent.layer.close(parent.layer.getFrameIndex(window.name)); ">关闭</button>
			</div>
		</div>
	</form>
	<script type="text/javascript" src="${base}/static/layui/layui.js"></script>
	<script type="text/javascript" src="${base}/static/js/wangEditor.min.js"></script>
	<script>
		layui.config({
			base : "${base}/static/layui/lay/mymodules/"
		}).use([ 'form', 'jquery', 'layer', 'cascader' ], function() {
			var form = layui.form, $ = layui.jquery, layer = layui.layer;
			
			var cas2 = layui.cascader({
				elem : "#refcataid",
				 url:'${base}${adminPrefix}/mall-pcata/cascaderdata',
				// data:[],
				// type: "post",
				// triggerType: "change",
				//showLastLevels : false,
				// where: {
				//     a: "aaa"
				// },
				value:['${mallPSpu.refOnecataId}','${mallPSpu.refTwocataId}'],
				success : function(valData, labelData) {
					console.log(valData, labelData);
					$('#refOnecataId').val(valData[0]);//一级
					$('#refTwocataId').val(valData[1]);//二级
				}
			});
			
			  var content_editor = new window.wangEditor('#content');
			  content_editor.customConfig.uploadImgServer = '${base}/file/uploadWang';
				content_editor.customConfig.uploadFileName = 'test';
		      // 关闭粘贴样式的过滤
		      content_editor.customConfig.pasteFilterStyle = false;
		      content_editor.customConfig.customAlert = function (info) {
		          // info 是需要提示的内容
		          layer.msg(info);
		      };
		      content_editor.create();

			form.on("submit(addMallPSpu)", function(data) {
				var loadIndex = layer.load(2, {
					shade : [ 0.3, '#333' ]
				});
				var c = content_editor.txt.html();
	                c = c.replace(/\"/g, "'");
	                data.field.content = c;
				//给角色赋值
				$.post("${base}${adminPrefix}/mall-pspu/edit", data.field,
						function(res) {
							layer.close(loadIndex);
							if (res.success) {
								parent.layer.msg("编辑成功！", {
									time : 1000
								}, function() {
									//刷新父页面
									parent.layui.table.reload('test');
									parent.layer.close(parent.layer.getFrameIndex(window.name));
								});
							} else {
								layer.msg(res.message);
							}
						});
				return false;
			});
			
		});
	</script>
</body>
</html>